#include "fac_task.h"
#include "stdio.h"
#include "module_config.h"
#include "wl_queue.h"
#include "bsp.h"

void fac_init(void)
{
    uart_rx_startDMA((UART_HandleTypeDef*)commEntity[DEBUG_COMM_TYPE].comm, commEntity[DEBUG_COMM_TYPE].rx.buf, commEntity[DEBUG_COMM_TYPE].rx.dmaBufSize);
}

static void commInterfacePackProc(COMM_TYPE_ENUM type, uint8_t* data, uint32_t size)
{
    process_at_cmd(0, size, (char*)data);
}

/**
  * @brief  task of at cmd
  * @param  void
  * @retval void
  */
void FacTaskEntry(void const * argument)
{
    Msg_st    stMsg;
    //int32_t   s32Ret = -1;

    fac_init();

    for (;;)
    {
        wl_queue_receive(WL_QUEUE_FAC_ID, &stMsg, 0xffffffff);

        switch (stMsg.u16MsgId)
        {
            #ifdef UART1_USING
            case WL_MSG_COMM_RX_UART1_DATA:
                commRxRingPopAndProcess(COMM_UART1, commInterfacePackProc);
                break;
            #endif

            case WL_MSG_SUBG_REINIT:
                subg_reinit();
                break;

            default:
                LOG_TS(AM_LOG_LEVEL_FATAL, "factask", "msg id err: %d\r\n", stMsg.u16MsgId);
                break;
        }
    }
}


